package itdep.domain.student;

import itdep.domain.IisEntity;
import itdep.domain.profile.Profile;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * todo: move expel reason to events
 * todo: diploma?
 * todo: education period (is there a need in this?)
 * todo: entrance type (may be move it to event?)
 * todo: hostel?
 * todo: graduation year (make one-to-many association with Organization with this data?)
 * todo: add student events
 * todo: student job?
 *
 * @author Ivan Khalopik
 * @version $Revision: 52 $ $Date: 2010-07-06 10:22:21 +0000 (Tue, 06 Jul 2010) $
 */
@Entity
@Table(name = "STUDENT")
public class Student extends IisEntity {

	@OneToOne
	private Profile profile;

	@Column(name = "PRIVACY_NUMBER", nullable = false)
	private String privacyNumber;

	@Column(name = "BOOK_NUMBER", nullable = false)
	private String bookNumber;

	@Type(type = "ga.hibernate.OrderedEnumUserType", parameters = {@Parameter(name = "enumClass", value = "itdep.domain.student.EducationType")})
	@Column(name = "EDUCATION_TYPE", nullable = false)
	private EducationType educationType;

	@Type(type = "ga.hibernate.OrderedEnumUserType", parameters = {@Parameter(name = "enumClass", value = "itdep.domain.student.EducationStatus")})
	@Column(name = "EDUCATION_STATUS", nullable = false)
	private EducationStatus educationStatus;

	@ManyToOne
	@JoinColumn(name = "ID_STUDENT_GROUP", nullable = false)
	private StudentGroup studentGroup;

	@ManyToMany
	@JoinTable(name = "STUDENT_SOCIAL_STATUS",
			joinColumns = @JoinColumn(name = "ID_STUDENT", nullable = false),
			inverseJoinColumns = @JoinColumn(name = "ID_SOCIAL_STATUS", nullable = false))
	private Set<SocialStatus> socialStatuses;

	@OneToMany(mappedBy = "student")
	private Set<StudentParent> studentParents = new HashSet<StudentParent>();

	@Type(type = "ga.hibernate.OrderedEnumUserType", parameters = {@Parameter(name = "enumClass", value = "itdep.domain.student.StudentPosition")})
	@Column(name = "STUDENT_POSITION", nullable = true)
	private StudentPosition studentPosition;

	@ManyToOne
	@JoinColumn(name = "ID_FOREIGN_LANGUAGE", nullable = false)
	private ForeignLanguage foreignLanguage;

	@Type(type = "ga.hibernate.OrderedEnumUserType", parameters = {@Parameter(name = "enumClass", value = "itdep.domain.student.AccommodationType")})
	@Column(name = "ACCOMMODATION_TYPE", nullable = false)
	private AccommodationType accommodationType;

	@OneToMany(mappedBy = "student")
	private Set<UserMark> userMarks;

	public Profile getProfile() {
		return profile;
	}

	public void setProfile(Profile profile) {
		this.profile = profile;
	}

	public String getPrivacyNumber() {
		return privacyNumber;
	}

	public void setPrivacyNumber(String privacyNumber) {
		this.privacyNumber = privacyNumber;
	}

	public String getBookNumber() {
		return bookNumber;
	}

	public void setBookNumber(String bookNumber) {
		this.bookNumber = bookNumber;
	}

	public EducationType getEducationType() {
		return educationType;
	}

	public void setEducationType(EducationType educationType) {
		this.educationType = educationType;
	}

	public EducationStatus getEducationStatus() {
		return educationStatus;
	}

	public void setEducationStatus(EducationStatus educationStatus) {
		this.educationStatus = educationStatus;
	}

	public StudentGroup getStudentGroup() {
		return studentGroup;
	}

	public void setStudentGroup(StudentGroup studentGroup) {
		this.studentGroup = studentGroup;
	}

	public Set<SocialStatus> getSocialStatuses() {
		return socialStatuses;
	}

	public void setSocialStatuses(Set<SocialStatus> socialStatuses) {
		this.socialStatuses = socialStatuses;
	}

	public Set<StudentParent> getStudentParents() {
		return studentParents;
	}

	public void setStudentParents(Set<StudentParent> studentParents) {
		this.studentParents = studentParents;
	}

	public StudentPosition getStudentPosition() {
		return studentPosition;
	}

	public void setStudentPosition(StudentPosition studentPosition) {
		this.studentPosition = studentPosition;
	}

	public ForeignLanguage getForeignLanguage() {
		return foreignLanguage;
	}

	public void setForeignLanguage(ForeignLanguage foreignLanguage) {
		this.foreignLanguage = foreignLanguage;
	}

	public AccommodationType getAccommodationType() {
		return accommodationType;
	}

	public void setAccommodationType(AccommodationType accommodationType) {
		this.accommodationType = accommodationType;
	}

	public Set<UserMark> getUserMarks() {
		return userMarks;
	}

	public void setUserMarks(Set<UserMark> userMarks) {
		this.userMarks = userMarks;
	}
}